<template>
  <div class="comment-reply">
    <van-nav-bar
      :title="
        comment.reply_count > 0 ? `有${comment.reply_count}条评论` : '暂无评论'
      "
    >
      <!-- 插槽 关闭弹窗按钮 -->
      <van-icon name="cross" slot="left" @click="$emit('close')" />
    </van-nav-bar>
    <!-- 复用两个组件 -->
    <div class="scroll-wrap">
      <comment-item :comment="comment" />
      <van-cell>全部评论</van-cell>
      <comment-list :list="list" :source="comment.com_id" type="c" />
    </div>
    <!-- 写评论 -->
    <div class="post-warp">
      <van-button
        @click="replyShow = true"
        class="post-btn"
        size="small"
        round
        plain
        >写评论</van-button
      >
    </div>
    <!-- 回复评论 -->
    <van-popup v-model="replyShow" position="bottom">
      <post-comment
        :target="comment.com_id"
        @post-success="
          (data) => {
            this.showPost = false;
            this.list.unshift(data);
          }
        "
      />
    </van-popup>
  </div>
</template>

<script>
import CommentItem from './comment-item'
import CommentList from './comment-list'
import PostComment from './comment-post'
export default {
  name: 'CommentReply',
  components: {
    CommentItem,
    CommentList,
    PostComment
  },
  inject: {
    articleId: {
      type: [String, Number, Object]
    }
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      replyShow: false
    }
  },
  created () {

  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
.scroll-wrap{
  position: fixed;
  top: 250px;
  left: 0;
  right: 0;
  bottom: 88px;
  overflow-y: auto;
}
.post-wrap{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  border-top: 1px solid #d8d8d8;
  .post-btn{
    width: 60%;
  }
}
</style>
